package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.MathProblem;

import java.util.Random;

/**
 * @author tzp
 * @since 2020/11/4
 */
public class LC470 implements MathProblem {
    public int rand10() {
        while (true) {
            int a = rand7();
            int b = rand7();
            int n = (a - 1) * 7 + b;
            if (n <= 40) {
                return n % 10 + 1;
            }
        }
    }

    Random rand = new Random();

    //return 1-7
    public int rand7() {
        return rand.nextInt(7) + 1;
    }

    public static void main(String[] args) {
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
        System.out.println(new LC470().rand10());
    }
}
